<?php
//symfony test:functional frontend homeActions

include(dirname(__FILE__).'/../../bootstrap/functional.php');

$browser = new sfTestFunctional(new sfBrowser());

$browser->
  get('/')->

  with('request')->begin()->
    isParameter('module', 'home')->
    isParameter('action', 'index')->
  end()->

  info("### HOME RESPONSE ###")->
  with('response')->begin()->
    isStatusCode(200)->
    checkElement('#menu', true)->
    checkElement('#logo', true)->
    checkElement('#presentazione', true)->
    checkElement('#presentazione p', 3)->
    checkElement('#campagne', true)->
    checkElement('#natale', true)->
    checkElement('#parlamentare', true)->
    info("### CAMPAGNE ###")->
    checkElement('#campagne #ddl-gelmini h1', "DDL Gelmini")->
    checkElement('#campagne #ddl-gelmini p', "Compra un No per affossare il decreto Gelmini")->
    checkElement('#campagne #ddl-gelmini .visualizza-commenti a', true)->
    checkElement('#campagne #ddl-gelmini .partecipa a', true)->
    checkElement('#campagne #ddl-gelmini .adesioni', true)->
    checkElement('#campagne #ddl-gelmini .adesioni', "Hanno già aderito 0 cittadini")->
  end()->

  info("### LINK ###")->
  click("Visualizza commenti")->
        
  with('request')->begin()->
    isParameter('module', 'partecipa')->
    isParameter('action', 'index')->
  end()->
        
  with('response')->begin()->
    isStatusCode(200)->
  end()->

  get('/home/index')->

  with('request')->begin()->
    isParameter('module', 'home')->
    isParameter('action', 'index')->
  end()->

  click("Partecipa anche tu")->

  with('request')->begin()->
    isParameter('module', 'partecipa')->
    isParameter('action', 'new')->
  end()->

  with('response')->begin()->
    isStatusCode(200)->
  end()
;
